<template>
  <view class="router-view container bcl-white">
    <view style="overflow: auto;" v-html="content"></view>
  </view>
</template>

<script>
import { infoProtocol } from "@/apis/app";

export default {
  data() {
    return {
      navigationBarTitles: {
        1: "项目交付协议",
        2: "任务发布协议",
        3: "关于志华网",
        4: "空间规划",
        5: "服务条款",
        6: "用户注册协议",
        7: "购买守则",
        8: "取消政策",
        9: "退款政策",
      },
      status: {
        1: "task_draft",
        2: "task",
        3: "about",
        4: "space",
        5: "service",
        6: "register",
      },
      type: 1,
      content: "",
    };
  },

  onLoad(options) {
    this.type = options.type;

    // 修改页面标题
    uni.setNavigationBarTitle({
      title: this.navigationBarTitles[this.type],
    });

    this.infoProtocol();
  },

  methods: {
    /**
     * 获取协议内容
     */
    async infoProtocol() {
      // if ([7, 8, 9].includes(Number(this.type))) return false;

      let params = {
        type: this.status[this.type],
      };

      let { code, data } = await infoProtocol(params);

      if (code == 200) this.content = data.content;
    },
  },
};
</script>
